package com.scs.application.modules.dept.controller;

import com.scs.application.core.mvc.controller.FlowController;
import com.scs.application.core.utils.UserUtils;
import com.scs.application.modules.dept.entity.Budget;
import com.scs.application.modules.dept.service.BudgetService;
import com.scs.application.modules.dept.util.UtilBudget;
import com.scs.application.modules.sys.model.RestResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * <p>
 *  前端控制器
 * </p>
 */
@RestController
@RequestMapping("/dept/budget")
public class BudgetController extends FlowController<BudgetService, Budget> {

    /**
     * 获取  登录科室当月预算
     * @return
     */
    @RequestMapping("/getBudgetForLoginUser")
    public RestResult getBudgetForLoginUser() {
      return RestResult.ok("查询成功", UtilBudget.getBudgetForLoginUser(UserUtils.currentUser().getDeptId()));
    }



    /**
     * 获取 上年限额限量  上月限额限量 本月消耗额 消耗量
     * @return
     */
    @RequestMapping("/getQtyAmount")
    public RestResult getQtyAmount(int year, int month, Date startDate, Date endDate, boolean flagHospital) {
        return RestResult.ok("查询成功", UtilBudget.getQtyAmount(year,month,UserUtils.currentUser().getDeptId(),startDate,endDate,flagHospital));
    }

    @GetMapping("/copy/{id}")
    public RestResult copy(@PathVariable String id) {
        return RestResult.ok("复制成功",service.copy(id));
    }
}
